using System;

namespace TSharp.Core.Util.TypeConvert
{
    /// <summary>
    /// 
    /// </summary>
    public class NullableInt64TypeDetectorImpl : NullableValueTypeDetector<long>
    {
        /// <summary>
        /// Strings the specified detector obj.
        /// </summary>
        /// <param name="detectorObj">The detector obj.</param>
        /// <param name="arg">The arg.</param>
        /// <returns></returns>
        public override long? String(string detectorObj, long? arg)
        {
            long result;
            bool parseSucceed = long.TryParse(detectorObj, out result);
            return parseSucceed ? result : arg;
        }

        /// <summary>
        /// Int64s the specified detector obj.
        /// </summary>
        /// <param name="detectorObj">The detector obj.</param>
        /// <param name="arg">The arg.</param>
        /// <returns></returns>
        public override Int64? Int64(Int64 detectorObj, Int64? arg)
        {
            return detectorObj;
        }
    }
}